/*
 +----------------------------------------------------------------------
 + Title        : 订单接口
 + Author       : huwl
 + Version      : 1.0.0
 + Initial-Time : 2023-08-11
 + Last-time    : 这个文件最后修改的时间 + 修改人的名称
 + Desc         : 订单接口
 +----------------------------------------------------------------------
*/

import { http } from '@/utils/httpRequest'

/**
 * 购物车结算创建订单
 * 
 * 参数data包含以下数据
 * {
 *      platform, ------------------------------------------------必传,商城平台
 *      username, ------------------------------------------------必传,用户名
 *      address_id, ----------------------------------------------必传,收货地址ID
 * }
 * return json
 * author huwl
 */
export const reqCreateOrderAPI = (data: any) => {
    return http({
        method: 'POST',
        url: 'order/create',
        data
    })
}

/**
 * 直接购买创建订单
 * 
 * 参数data包含以下数据
 * {
 *      goods_sku_id, --------------------------------------------必传,商品规格选项ID
 *      num, -----------------------------------------------------必传,商品数量
 *      platform, ------------------------------------------------必传,商城平台
 *      username, ------------------------------------------------必传,用户名
 *      address_id, ----------------------------------------------必传,收货地址ID
 * }
 * 
 * return json
 * author huwl
 */
export const reqGenerateOrderAPI = (data: any) => {
    return http({
        method: 'POST',
        url: 'order/generate',
        data
    })
}

/**
 * 订单详情
 * 
 * @param int oid -----------------------------------------------------必传,订单ID
 * @param int is_have_logistics ---------------------------------------非必传,是否需要物流信息
 * return json
 * author huwl
 */
export const reqOrderDetailAPI = (oid: any, is_have_logistics?: any) => {
    return http({
        method: 'GET',
        url: 'order/detail',
        data: { oid, is_have_logistics }
    })
}

/**
 * 订单列表
 * 
 * 参数data包含以下数据
 * {
 *      status, --------------------------------------------------非必传,订单状态
 *      page, ----------------------------------------------------非必传,页码
 *      page_size, -----------------------------------------------非必传,条数
 * }
 * return json
 * author huwl
 */
export const reqOrderListAPI = (data: any) => {
    return http({
        method: 'GET',
        url: 'order/list',
        data
    })
}

/**
 * 订单数量
 * 
 * 参数data包含以下数据
 * {
 *      status, --------------------------------------------------非必传,订单状态
 *      page, ----------------------------------------------------非必传,页码
 *      page_size, -----------------------------------------------非必传,条数
 * }
 * return json
 * author huwl
 */
export const reqOrderTotalAPI = (data: any) => {
    return http({
        method: 'GET',
        url: 'order/total',
        data
    })
}

/**
 * 取消订单
 * 
 * 参数data包含以下数据
 * {
 *      oid, -----------------------------------------------------必传,订单状态
 *      cancel_reason, -------------------------------------------非必传,取消原因
 * }
 * return json
 * author huwl
 */
export const reqCancelOrderAPI = (data: any) => {
    return http({
        method: 'POST',
        url: 'order/cancel',
        data
    })
}

/**
 * 确认订单
 * 
 * @param oid -----------------------------------------------------必传,订单ID
 * return json
 * author huwl
 */
export const reqConfirmOrderAPI = (oid: any) => {
    return http({
        method: 'POST',
        url: 'order/confirm',
        data: { oid }
    })
}

/**
 * 删除订单
 * 
 * @param oid -----------------------------------------------------必传,订单ID
 * return json
 * author huwl
 */
export const reqDeleteOrderAPI = (oid: any) => {
    return http({
        method: 'POST',
        url: 'order/delete',
        data: { oid }
    })
}

/**
 * 支付订单
 * 
 * @param oid -----------------------------------------------------必传,订单ID
 * return json
 * author huwl
 */
export const reqPaymentOrderAPI = (oid: any) => {
    return http({
        method: 'POST',
        url: 'order/payment',
        data: { oid }
    })
}

/**
 * 订单退款
 * 
 * @param oid -----------------------------------------------------必传,订单ID
 * return json
 * author huwl
 */
export const reqRefundOrderAPI = (oid: any) => {
    return http({
        method: 'POST',
        url: 'order/refund',
        data: { oid }
    })
}